/*	Copyright 2008 Jacquemin Valentin

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
	
	@author pollux
 */
package org.poxd.model;

import java.text.Collator;
import java.util.Map;

/**
 * @author pollux
 * 
 */
public class Language implements Comparable<Language> {
	private Integer id;
	private String name;
	private String marker;
	private Map<String, Category> categories;
	private Content icon;
	private static final Collator COMPARATOR = Collator.getInstance();

	public Language() {
		this("");
	}

	public Language(String name) {
		super();
		this.name = name;
	}

	public Language(String name, Map<String, Category> categories, Content icon) {
		super();
		this.name = name;
		this.categories = categories;
		this.icon = icon;
	}

	public Language(String name, Content icon) {
		super();
		this.name = name;
		this.icon = icon;
	}

	public Language(String name, String marker, Content icon) {
		super();
		this.name = name;
		this.marker = marker;
		this.icon = icon;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getMarker() {
		return marker;
	}

	public void setMarker(String marker) {
		this.marker = marker;
	}

	public Map<String, Category> getCategories() {
		return categories;
	}

	public void setCategories(Map<String, Category> categories) {
		this.categories = categories;
	}

	public Content getIcon() {
		return icon;
	}

	public void setIcon(Content icon) {
		this.icon = icon;
	}

	@Override
	public boolean equals(Object obj) {
		return obj instanceof Language
				&& ((Language) obj).getName().equalsIgnoreCase(name);
	}

	@Override
	public int hashCode() {
		return name.hashCode();
	}

	@Override
	public String toString() {
		return getName() + " [id=" + getId() + "] - " + getMarker() + " - "
				+ getIcon().getAbsolutepath();
	}

	public int compareTo(Language o) {
		return COMPARATOR.compare(this.name, o.getName());
	}
}
